/*
	author: TangQiao , Wind @ Beijing Normal University

	problem name: Babelfish
	
	source : PKU Online Judge
	
	problem type: 字符串操作题 
	
	problem description: 给你一个字典,字典最多有100,000 个单词.让你进行单词的翻译. 
	
	problem solution: 只有用map了,这题也是我以前优化了好久没有过的题.
 					  用map只一下就搞定了. 
	
	date : 2005.8.21 12:27	PKU2503 STL MAP的应用	  	
	
*/
#include <stdio.h>
#include <iostream>
#include <string>
#include <map>
using namespace std;

map<string,string> word;
map<string,string>::iterator pos;
string str1 , str2;

main()
{
	char ss[50], s1[11], s2[11] ;

	while (gets(ss))
	{
		while (strlen(ss)==0) gets(ss);
		if (strstr(ss," ")==0) break;
		sscanf(ss,"%s %s", s1, s2);
		str1 = s1;
		str2 = s2;
		word[str2] = str1;
	} 

	sscanf(ss,"%s", s1);
	do 
	{
		while (strlen(s1)==0) gets(s1);
		pos = word.find(s1);
		
		if (pos == word.end() ) cout << "eh" << endl;
		else  cout << pos->second << endl;
		
	} while(gets(s1));


	return 0;
}
